package com.yunxin.core.application.assembler;

import com.yunxin.core.application.command.order.*;
import com.yunxin.core.application.dto.order.*;
import com.yunxin.core.customer.vo.CustomerInfoDetailVo;
import com.yunxin.core.domain.model.order.OrderUserApply;
import com.yunxin.core.domain.model.order.OrderUserApplyDetail;
import com.yunxin.core.domain.model.order.OrderUserUv;
import com.yunxin.core.infra.persistence.entity.order.query.condition.OrderUserApplyAllocationMerchantPageCondition;
import com.yunxin.core.infra.persistence.entity.order.query.condition.OrderUserApplyAllocationPageCondition;
import com.yunxin.core.infra.persistence.entity.order.query.condition.OrderUserApplyPageCondition;
import com.yunxin.core.infra.persistence.entity.order.query.result.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * @author zero°
 * @since 2023-05-28
 */
@Mapper(componentModel = "spring")
public interface OrderAssembler {

    /**
     * result 转 dto
     * @param result result
     * @return OrderUserApplyDetailDTO
     */
    @Mapping(target = "loanPeriod", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getLoanPeriod(), com.yunxin.core.utils.infra.common.enums.LoanPeriodEnum.class))")
    @Mapping(target = "educationLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getEducationLevel(), com.yunxin.core.utils.infra.common.enums.EducationLevelEnum.class))")
    @Mapping(target = "creditCard", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getCreditCard(), com.yunxin.core.utils.infra.common.enums.CreditCardEnum.class))")
    @Mapping(target = "microLoanQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getMicroLoanQuota(), com.yunxin.core.utils.infra.common.enums.MicroLoanQuotaEnum.class))")
    @Mapping(target = "sesameSeedQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSesameSeedQuota(), com.yunxin.core.utils.infra.common.enums.SesameSeedQuotaEnum.class))")
    @Mapping(target = "occupation", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getOccupation(), com.yunxin.core.utils.infra.common.enums.OccupationEnum.class))")
    @Mapping(target = "occupationMonthlyIncome", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getOccupationMonthlyIncome(), com.yunxin.core.utils.infra.common.enums.OccupationIncomeEnum.class))")
    @Mapping(target = "houseLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getHouseLevel(), com.yunxin.core.utils.infra.common.enums.HouseLevelEnum.class))")
    @Mapping(target = "vehicleLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getVehicleLevel(), com.yunxin.core.utils.infra.common.enums.VehicleLevelEnum.class))")
    @Mapping(target = "insure", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getInsure(), com.yunxin.core.utils.infra.common.enums.InsureEnum.class))")
    @Mapping(target = "accumulationFundLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getAccumulationFundLevel(), com.yunxin.core.utils.infra.common.enums.AccumulationFundLevelEnum.class))")
    @Mapping(target = "socialSecurityLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSocialSecurityLevel(), com.yunxin.core.utils.infra.common.enums.SocialSecurityLevelEnum.class))")
    @Mapping(target = "jdBtQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getJdBtQuota(), com.yunxin.core.utils.infra.common.enums.JdBtQuotaEnum.class))")
    @Mapping(target = "antCreditPayQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getAntCreditPayQuota(), com.yunxin.core.utils.infra.common.enums.AntCreditPayEnum.class))")
    @Mapping(target = "gender", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSex(), com.yunxin.core.utils.infra.common.enums.SexEnum.class))")
    @Mapping(target = "beOverdue", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getBeOverdue(), com.yunxin.core.utils.infra.common.enums.BeOverdueEnum.class))")
    OrderUserApplyDetailDTO toOrderUserApplyDetailDTO(OrderUserApplyDetailResult result);


    /**
     * result 转 dto
     * @param result result
     * @return OrderUserApplyDetailDTO
     */
    @Mapping(target = "loanPeriod", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getLoanPeriod(), com.yunxin.core.utils.infra.common.enums.LoanPeriodEnum.class))")
    @Mapping(target = "educationLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getEducationLevel(), com.yunxin.core.utils.infra.common.enums.EducationLevelEnum.class))")
    @Mapping(target = "creditCard", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getCreditCard(), com.yunxin.core.utils.infra.common.enums.CreditCardEnum.class))")
    @Mapping(target = "microLoanQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getMicroLoanQuota(), com.yunxin.core.utils.infra.common.enums.MicroLoanQuotaEnum.class))")
    @Mapping(target = "sesameSeedQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSesameSeedQuota(), com.yunxin.core.utils.infra.common.enums.SesameSeedQuotaEnum.class))")
    @Mapping(target = "occupation", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getOccupation(), com.yunxin.core.utils.infra.common.enums.OccupationEnum.class))")
    @Mapping(target = "occupationMonthlyIncome", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getOccupationMonthlyIncome(), com.yunxin.core.utils.infra.common.enums.OccupationIncomeEnum.class))")
    @Mapping(target = "houseLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getHouseLevel(), com.yunxin.core.utils.infra.common.enums.HouseLevelEnum.class))")
    @Mapping(target = "vehicleLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getVehicleLevel(), com.yunxin.core.utils.infra.common.enums.VehicleLevelEnum.class))")
    @Mapping(target = "insure", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getInsure(), com.yunxin.core.utils.infra.common.enums.InsureEnum.class))")
    @Mapping(target = "accumulationFundLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getAccumulationFundLevel(), com.yunxin.core.utils.infra.common.enums.AccumulationFundLevelEnum.class))")
    @Mapping(target = "socialSecurityLevel", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSocialSecurityLevel(), com.yunxin.core.utils.infra.common.enums.SocialSecurityLevelEnum.class))")
    @Mapping(target = "jdBtQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getJdBtQuota(), com.yunxin.core.utils.infra.common.enums.JdBtQuotaEnum.class))")
    @Mapping(target = "antCreditPayQuota", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getAntCreditPayQuota(), com.yunxin.core.utils.infra.common.enums.AntCreditPayEnum.class))")
    @Mapping(target = "gender", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSex(), com.yunxin.core.utils.infra.common.enums.SexEnum.class))")
    @Mapping(target = "beOverdue", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getBeOverdue(), com.yunxin.core.utils.infra.common.enums.BeOverdueEnum.class))")
    OrderUserApplyDetailDTO toCustomerInfoDetailVo(CustomerInfoDetailVo result);

    /**
     * result 转 dto
     * @param result result
     * @return OrderUserApplyPageDTO
     */
    @Mapping(target = "sesameSeedQuotaStr", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSesameSeedQuota(), com.yunxin.core.utils.infra.common.enums.SesameSeedQuotaEnum.class))")
    OrderUserApplyPageDTO toOrderUserApplyPageDTO(OrderUserApplyPageResult result);
    /**
     * result 转 dto
     * @param result result
     * @return UserApplyOrderInfoDTO
     */
    UserApplyOrderInfoDTO toUserApplyOrderInfoDTO(OrderUserApplyInfoResult result);

    /**
     * result 转 dto
     * @param result result
     * @return OrderUserApplyAllocationPageDTO
     */
    @Mapping(target = "sesameSeedQuotaStr", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getSesameSeedQuota(), com.yunxin.core.utils.infra.common.enums.SesameSeedQuotaEnum.class))")
    OrderUserApplyAllocationPageDTO toOrderUserApplyAllocationPageDTO(OrderUserApplyAllocationPageResult result);

    /**
     * result 转 dto
     * @param result result
     * @return OrderUserApplyAllocationMerchantPageDTO
     */
    @Mapping(target = "orderStatusStr", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getOrderStatus(), com.yunxin.core.infra.common.order.enums.AllocationOrderStatusEnum.class))")
    @Mapping(target = "loanPeriodStr", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getLoanPeriod(), com.yunxin.core.utils.infra.common.enums.LoanPeriodEnum.class))")
    OrderUserApplyAllocationMerchantPageDTO toOrderUserApplyAllocationMerchantPageDTO(OrderUserApplyAllocationMerchantPageResult result);



    /**
     * command 转 condition
     * @param command command
     * @return OrderUserApplyPageCondition
     */
    @Mapping(target = "startAllocationTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByStartTimeStr(command.getStartAllocationTime()))")
    @Mapping(target = "endAllocationTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByEndTimeStr(command.getEndAllocationTime()))")
    @Mapping(target = "startSubmitTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByStartTimeStr(command.getStartSubmitTime()))")
    @Mapping(target = "endSubmitTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByEndTimeStr(command.getEndSubmitTime()))")
    OrderUserApplyPageCondition formOrderUserApplyPageCommand(OrderUserApplyPageCommand command);

    /**
     * command 转 entity
     * @param command command
     * @return OrderUserApply
     */
    OrderUserApply formCreateUserApplyOrderCommand(CreateUserApplyOrderCommand command);

    /**
     * command 转 entity
     * @param command command
     * @return OrderUserApplyDetail
     */
    OrderUserApplyDetail formCreateUserApplyOrderCommandForDetail(CreateUserApplyOrderCommand command);

    /**
     * command 转 condition
     * @param command command
     * @return OrderUserApplyAllocationPageCondition
     */
    @Mapping(target = "startAllocationTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByStartTimeStr(command.getStartAllocationTime()))")
    @Mapping(target = "endAllocationTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByEndTimeStr(command.getEndAllocationTime()))")
    @Mapping(target = "startSubmitTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByStartTimeStr(command.getStartSubmitTime()))")
    @Mapping(target = "endSubmitTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByEndTimeStr(command.getEndSubmitTime()))")
    OrderUserApplyAllocationPageCondition formOrderUserApplyAllocationPageCommand(OrderUserApplyAllocationPageCommand command);

    /**
     * command 转 condition
     * @param command command
     * @return OrderUserApplyAllocationMerchantPageCondition
     */
    @Mapping(target = "startAllocationTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByStartTimeStr(command.getStartAllocationTime()))")
    @Mapping(target = "endAllocationTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByEndTimeStr(command.getEndAllocationTime()))")
    @Mapping(target = "startSubmitTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByStartTimeStr(command.getStartSubmitTime()))")
    @Mapping(target = "endSubmitTime", expression = "java(com.yunxin.core.utils.infra.utils.DateFormatUtils.X.getDateByEndTimeStr(command.getEndSubmitTime()))")
    OrderUserApplyAllocationMerchantPageCondition formOrderUserApplyAllocationMerchantPageCommand(OrderUserApplyAllocationMerchantPageCommand command);


    /**
     * command 转 entity
     * @param command command
     * @return OrderUserUv
     */
    OrderUserUv formCreateUserUvOrderCommand(CreateUserUvOrderCommand command);
}
